class Solution {
public:
    void rotate(vector<int>& nums, int k) {
        int n = nums.size();
        deque<int>q;
        for (int i = 0; i < n; i++)
        {
            q.push_back(nums[i]);
        }

        for (int i = 0; i < k; i++)
        {
            q.push_front(q.back());
            q.pop_back();
        }
        for (int i = 0; i < n; i++)
        {
            nums[i] = q[i];
        }
    }
};